﻿#ifndef TCPCLIENT_H
#define TCPCLIENT_H

#include <QObject>
#include <QTcpSocket>
#include <dbHelper.h>
#include <QThread>
#include <QDebug>
#include <QTimer>
#include <QHostAddress>
#include <CommonHelper.h>
#include <dbHelper.h>
#include "loghelper.h"
#include <intListener.h>
#include "qmlSignal.h"
#include "logHelperJ.h"

//该对象最终运行在次线程中
class TcpClient : public QTcpSocket
{
    Q_OBJECT
public:
    TcpClient(QObject *parent = NULL);
    ~TcpClient();
public:
    void ClientConnectToHost(const QString &address, quint16 port);
    void ClientSendingData(const QByteArray &c_btaData);
    bool IsOnline();
    void GetTempRun();
    static intListener startExperimentStatus;
signals:
    //转换来自主线程的链接操作
    void SignalConnectToHost(const QString & address, quint16 port);

    //转换来自主线程的发送操作
    void SignalSendingData(const QByteArray c_btaData);
    void successStart();

public:
    int experimentStatus;
    int tempOrder;
    QString equId;
    int reInfoStatus;
    QString experimentGuid;
    QString chartStatus;
    QString step;
    QString cycle;
    QString temp;
    QString tempTwo;
    QString tempThree;
    QString tempFour;
    QString tempFive;
    QString tempSix;
    QString allerror;

private:
    //标记连接情况
    bool m_bOnLine = false;
    CommonHelper* common;
    loghelper * logClient;
    QString tempString;
    int reNum;
    QTcpSocket *socket;
    QMap<QString, QString> *mapGZ;

};


#endif // TCPCLIENT_H
